import { Column, Entity } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { BaseEntity } from 'src/common/entities/base';

@Entity('sys_login_log', {
  comment: '登录注册记录表',
})
export class LoginLogEntity extends BaseEntity {
  @ApiProperty({ type: String, description: '用户名' })
  @Column({ type: 'varchar', name: 'user_name', length: 30, nullable: false, comment: '用户账号' })
  public userName: string;

  @ApiProperty({ type: String, description: '用户id' })
  @Column({ type: 'bigint', name: 'user_id', comment: '用户id' })
  public userId: number;

  @ApiProperty({ type: String, description: '登录ip' })
  @Column({ type: 'varchar', length: 128, nullable: true, comment: '登录ip' })
  public ipaddr: string;

  @ApiProperty({ type: String, description: '登录位置' })
  @Column({ type: 'varchar', length: 255, nullable: true, comment: '登录ip' })
  public location: string;

  @ApiProperty({ type: String, description: '浏览器UA' })
  @Column({ type: 'varchar', length: 255, nullable: true, comment: '浏览器UA' })
  userAgent: string;

  @ApiProperty({ type: String, description: '浏览器' })
  @Column({ type: 'varchar', length: 255, nullable: true, comment: '浏览器' })
  browser: string;

  @ApiProperty({ type: String, description: '系统' })
  @Column({ type: 'varchar', length: 255, nullable: true, comment: '系统' })
  os: string;

  @ApiProperty({ type: String, description: '记录类型 0 登录 1注册' })
  @Column({ type: 'char', length: 1, comment: '记录类型 0 登录 1注册' })
  type: '0' | '1';
}
